package garden {
	import org.davekeen.flextrine.orm.PersistentCollection;
	import org.davekeen.flextrine.orm.FlextrineError;
  	import garden.Tree;
   	import garden.Flower;
  
	[Bindable]
	public class GardenEntityBase {
		
		public var isUnserialized__:Boolean;
		
		public var isInitialized__:Boolean = true;
		
		public var isCollectionInitializedMap__:Object = new Object();
		
		[Id]
		public var id:String;
		
		public function get name():String { checkIsInitialized("name"); return _name; }
		public function set name(value:String):void { _name = value; }
		private var _name:String;
		
		[Association]
		public function get trees():PersistentCollection { checkIsInitialized("trees"); return _trees; }
		public function set trees(value:PersistentCollection):void { _trees = value; }
		private var _trees:PersistentCollection;
		
		[Association]
		public function get flowers():PersistentCollection { checkIsInitialized("flowers"); return _flowers; }
		public function set flowers(value:PersistentCollection):void { _flowers = value; }
		private var _flowers:PersistentCollection;
		
		public function GardenEntityBase() {
			trees = new PersistentCollection();
			flowers = new PersistentCollection();
		}
		
		public function toString():String {
			return "[Garden id=" + id + "]";
		}
		
		private function checkIsInitialized(property:String):void {
			if (!isInitialized__ && isUnserialized__)
				throw new FlextrineError("Attempt to get property '" + property + "' on unitialized Garden.  Consider using EntityManager::require or eager loading.", FlextrineError.ACCESSED_UNITIALIZED_ENTITY);
		}
		
	}

}
